﻿Public Class RcargarDocumentos

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal cargarDcmto As EcargarDocumentos) As List(Of EcargarDocumentos)
        Dim loadDcmtos As List(Of EcargarDocumentos) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                loadDcmtos = DcargarDocumentos.SeleccionarTodo(descEmpresa, cargarDcmto)
                If loadDcmtos Is Nothing Then loadDcmtos = New List(Of EcargarDocumentos)
                If DisplaySelect Then loadDcmtos.Insert(0, New EcargarDocumentos("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return loadDcmtos
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pCargarDcmto As EcargarDocumentos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DcargarDocumentos.Añadir(descEmpresa, pCargarDcmto)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pCargarDcmto As EcargarDocumentos) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DcargarDocumentos.Eliminar(descEmpresa, pCargarDcmto)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

End Class
